import request from '@/utils/request';

// 查询当前版本支持的模块列表
export function listModuleData(): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/system/config/version/list',
		method: 'get',
	});
}

// 查询参数列表
export function listConfig(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/param/page',
		method: 'get',
		params: query,
	});
}

// 查询参数详细
export function getConfig(configId: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/param/' + configId,
		method: 'get',
	});
}

// 根据参数键名查询参数值
export function getConfigKey(configKey: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/system/config/configKey/' + configKey,
		method: 'get',
	});
}

// 新增参数配置
export function addConfig(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/param',
		method: 'post',
		data: data,
	});
}

// 修改参数配置
export function updateConfig(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/param',
		method: 'put',
		data: data,
	});
}

// 删除参数配置
export function delConfig(publicId: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/param/' + publicId,
		method: 'delete',
	});
}

// 清理参数缓存
export function clearCache(): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/param/sync',
		method: 'put',
	});
}

// 导出参数
export function exportConfig(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/system/config/export',
		method: 'get',
		params: query,
	});
}
